package lion.mail;

import java.util.UUID;

import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

/**
 * @author lion
 * @email hl_0074@sina.com
 * @date 2015年5月20日
 */
public class MSGIDMessage extends MimeMessage {

	public MSGIDMessage(Session session) {

		super(session);
	}

	@Override
	protected void updateMessageID() throws MessagingException {

		InternetAddress address = (InternetAddress) this.getFrom()[0];

		String id = UUID.randomUUID().toString().replace("-", "") + "@" + address.getAddress().replaceAll(".*@", "");

		setHeader("Message-ID", "<" + id + ">");
	}
}
